<?php 

require_once '../mysqlConnect.php';

if (isset($_POST)) {
	
	$id = $_POST['id'];
	$anxiety = $_POST['anxiety'];
	$depression = $_POST['depression'];
	$cognition = $_POST['cognition'];
	$global = $_POST['global'];
	$date = $_POST['date'];

	
	if ($date == "" || $date == null)
		$returnValue = 'missing';	
	
	$sql = "UPDATE psychological_test_answers SET qnumber1 = '" . $anxiety . "', qnumber2 = '" . $depression . "', qnumber3 = '" . $cognition . "', global = '" . $global . "', record_date = '" . $date . "' WHERE id = '" . $id . "' LIMIT 1";
	
	$conn = GetConnection();
	$conn->query($sql);
	if ($conn->connect_errno)
		$returnValue = 'error';
	elseif ($conn->error)
		$returnValue = 'error';
	else
		$returnValue = 'success';
	
	echo $returnValue;
}